#include "minizincvariable.h"

#include <sstream>
#include <stdio.h>

MiniZincVariable::MiniZincVariable(const string & tableName, const string & columnName, int rowIndex, ColumnType type, int length):SymbolicVariable(tableName,columnName,rowIndex,type,length)
{

}

MiniZincVariable::MiniZincVariable(const MiniZincVariable & other):SymbolicVariable(other.tableName,other.columnName,other.rowIndex,other.type)
{

}

MiniZincVariable::MiniZincVariable(SymbolicVariable * sv):SymbolicVariable(*sv)
{

}

MiniZincVariable::~MiniZincVariable()
{

}

Expression * MiniZincVariable::clone()
{
	return new MiniZincVariable(*this);
}

string MiniZincVariable::toString()
{
	string str = "";
	str = str + tableName + "_" + columnName + "_";

	char buffer [33];
	sprintf(buffer,"%d",rowIndex);
	string str_rows(buffer);
	str = str + str_rows;

    return str;
}

string MiniZincVariable::toOutputString(){
  string str="";
  switch (getType().type){
  case(INTEGER):
    str = str + "show(" + (this->toString()) + ")";
    break;
  case (BOOLEAN):
    str = str + "show(" + (this->toString()) + ")";
  case(STRING):{
    str = str + "\"CHAR(\",";
    for (int i =0; i<getType().size; i++){
	    
      str = str + "show("+(this->toString())+"[";
	    
      char buffer [33];
      sprintf(buffer,"%d",i);
      string str_i(buffer);
      str = str + str_i;
      str= str + "]),";	
    }
    str.erase(str.length()-1);
    str= str+",\")\"";
    break;
  }
  default:
    break;
  }
  return str;
}
